﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using SlamDunk.MES.Domain.Entities.StockContext;

namespace SlamDunk.MES.Repository.EntityConfigurations.StockContext
{
    /// <summary>
    /// 物料条码实体映射配置
    /// </summary>
    public class MaterialBarcodeConfig : IEntityTypeConfiguration<MaterialBarcode>
    {
        /// <summary>
        /// 配置
        /// </summary>
        public void Configure(EntityTypeBuilder<MaterialBarcode> builder)
        {
            //配置属性
            builder.HasKey(materialBarcode => materialBarcode.Id).IsClustered(false);
            builder.Property(materialBarcode => materialBarcode.Number).IsRequired().HasMaxLength(16);

            //配置索引
            builder.HasIndex(materialBarcode => materialBarcode.AddedTime).IsUnique(false).IsClustered();
            builder.HasIndex(materialBarcode => materialBarcode.Number).IsUnique();
        }
    }
}
